package com.freesky.web.manager.service.impl;

import com.freesky.common.dao.entity.OrderItem;
import com.freesky.common.dao.mapper.OrderItemMapper;
import com.freesky.common.exception.EMallException;
import com.freesky.web.manager.service.SystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Freesky
 */
@Service
@Slf4j
public class SystemServiceImpl implements SystemService {
    @Autowired
    private OrderItemMapper orderItemMapper;

    @Value("${base.id}")
    private String baseId;



    @Override
    public OrderItem getWeekHot() {

        List<OrderItem> list = orderItemMapper.getWeekHot();
        if (list == null) {
            throw new EMallException("获取热销商品数据失败");
        }
        if (list.size() == 0) {
            OrderItem orderItem = new OrderItem();
            orderItem.setTotal(0);
            orderItem.setTitle("暂无数据");
            orderItem.setPicPath("");
            return orderItem;
        }
        return list.get(0);
    }

}
